package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.cld.domain.vo.CldTemporaryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldTemporary;
import com.cleaningcloud.cld.service.ICldTemporaryService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 临时工作安排信息Controller
 * 
 * @author cleaningcloud
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/temporary")
public class CldTemporaryController extends BaseController
{
    @Autowired
    private ICldTemporaryService cldTemporaryService;

    /**
     * 查询临时工作安排信息列表
     */
    @RequiresPermissions("cld:temporary:list")
    @GetMapping("/list")
    public TableDataInfo list(CldTemporaryVo cldTemporaryVo)
    {
        startPage();
        List<CldTemporaryVo> list = cldTemporaryService.selectCldTemporaryList(cldTemporaryVo);
        return getDataTable(list);
    }

    /**
     * 导出临时工作安排信息列表
     */
    @RequiresPermissions("cld:temporary:export")
    @Log(title = "临时工作安排信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldTemporaryVo cldTemporaryVo)
    {
        List<CldTemporaryVo> list = cldTemporaryService.selectCldTemporaryList(cldTemporaryVo);
        ExcelUtil<CldTemporaryVo> util = new ExcelUtil<CldTemporaryVo>(CldTemporaryVo.class);
        util.exportExcel(response, list, "临时工作安排信息数据");
    }

    /**
     * 获取临时工作安排信息详细信息
     */
    @RequiresPermissions("cld:temporary:query")
    @GetMapping(value = "/{temporaryId}")
    public AjaxResult getInfo(@PathVariable("temporaryId") Long temporaryId)
    {
        return success(cldTemporaryService.selectCldTemporaryByTemporaryId(temporaryId));
    }

    /**
     * 新增临时工作安排信息
     */
    @RequiresPermissions("cld:temporary:add")
    @Log(title = "临时工作安排信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldTemporary cldTemporary)
    {
        return toAjax(cldTemporaryService.insertCldTemporary(cldTemporary));
    }

    /**
     * 修改临时工作安排信息
     */
    @RequiresPermissions("cld:temporary:edit")
    @Log(title = "临时工作安排信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldTemporary cldTemporary)
    {
        return toAjax(cldTemporaryService.updateCldTemporary(cldTemporary));
    }

    /**
     * 删除临时工作安排信息
     */
    @RequiresPermissions("cld:temporary:remove")
    @Log(title = "临时工作安排信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{temporaryIds}")
    public AjaxResult remove(@PathVariable Long[] temporaryIds)
    {
        return toAjax(cldTemporaryService.deleteCldTemporaryByTemporaryIds(temporaryIds));
    }
}
